package org.create.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;


public class ReadProperties {
    private static final Properties pro = new Properties();
    private static final Map<String, String> dataMap = new ConcurrentHashMap<>();

    static {
        InputStream inputStream = ReadProperties.class.getClassLoader().getResourceAsStream("application.properties");
        try {
            pro.load(inputStream);
            for (Object o : pro.keySet()) {
                String key = (String) o;
                dataMap.put(key, pro.getProperty(key));
            }
        } catch (IOException e) {
            LogTool.printError(e);
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    LogTool.printError(e);
                }
            }
        }
    }

    public static String getValue(String key) {
        return dataMap.get(key);
    }
}
